home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 008a / fgdemo10.zip / FILE.C < prev    next >
Text File  |  1991-10-02  |  12KB  |  438 lines

  1. /**********************************************************************\
  2. *                                                                      *
  3. *  file.c -- routines for performing the functions on the FILE menu    *
  4. *                                                                      *
  5. \**********************************************************************/
  6.  
  7. #include "defs.h"
  8.  
  9. /**********************************************************************\
  10. *                                                                      *
  11. *  about_demo -- information about this demo program                   *
  12. *                                                                      *
  13. \**********************************************************************/
  14.  
  15. int about_demo()
  16. {
  17.    static char *string[] = {
  18.    "About This Demo",
  19.    "This demonstration program was written by",
  20.    "Diana Gruber, using Fastgraph from Ted Gruber",
  21.    "Software.  You may distribute this program",
  22.    "freely, but please do not distribute any",
  23.    "modified versions.  This program is distributed",
  24.    "with source code.  You may use this source",
  25.    "code in your Fastgraph applications.",
  26.    "",
  27.    "        Copyright 1991 Diana Gruber"
  28.    };
  29.  
  30.    /* clear the screen and display the info window */
  31.  
  32.    fg_mousevis(OFF);
  33.    fg_restore(0,xlimit,menu_bottom,ylimit);
  34.    info_window(120,520,60,string,10);
  35.  
  36.    /* wait for a keystroke or mouse button */
  37.  
  38.    fg_mousevis(ON);
  39.    wait_for_keystroke();
  40.  
  41.    /* restore the screen and return to the menu */
  42.  
  43.    fg_mousevis(OFF);
  44.    fg_restore(0,xlimit,menu_bottom,ylimit);
  45.  
  46.    fg_mousevis(ON);
  47.    redraw = TRUE;
  48.  
  49.    return(OK);
  50. }
  51.  
  52. /**********************************************************************\
  53. *                                                                      *
  54. *  about_docs -- information about this Fastgraph Documentation        *
  55. *                                                                      *
  56. \**********************************************************************/
  57.  
  58. int about_docs()
  59. {
  60.    static char *string[] = {
  61.    "Fastgraph Documentation",
  62.    "The Fastgraph manuals are exceptionally good.  The",
  63.    "250-page Fastgraph User's Guide provides information",
  64.    "about graphics concepts, suggestions about how to",
  65.    "use Fastgraph, and 120 example programs.  The",
  66.    "Fastgraph Reference Manual provides an alphabetical",
  67.    "summary of each Fastgraph routine.  Even a novice",
  68.    "programmer should be able to use Fastgraph with very",
  69.    "little difficulty."
  70.    };
  71.  
  72.    /* clear the screen and display the info window */
  73.  
  74.    fg_mousevis(OFF);
  75.    fg_restore(0,xlimit,menu_bottom,ylimit);
  76.    info_window(100,540,60,string,9);
  77.  
  78.    /* wait for a keystroke or mouse button */
  79.  
  80.    fg_mousevis(ON);
  81.    wait_for_keystroke();
  82.  
  83.    /* clear the screen and return to the menu */
  84.  
  85.    fg_mousevis(OFF);
  86.    fg_restore(0,xlimit,menu_bottom,ylimit);
  87.  
  88.    fg_mousevis(ON);
  89.    redraw = TRUE;
  90.  
  91.    return(OK);
  92. }
  93.  
  94. /**********************************************************************\
  95. *                                                                      *
  96. *  about_fg -- display about Fastgraph information                     *
  97. *                                                                      *
  98. \**********************************************************************/
  99.  
  100. int about_fg()
  101. {
  102.    static char *string[] = {
  103.    "About Fastgraph",
  104.    "Fastgraph, the Programmer's Graphics Library by",
  105.    "Ted Gruber Software, is a collection of over 150",
  106.    "highly optimized routines callable from C, BASIC",
  107.    "and Fortran.  Fastgraph gives the programmer",
  108.    "complete control over the DOS-based text and",
  109.    "graphics video environment.",
  110.    };
  111.  
  112.    /* clear the screen and display the info window */
  113.  
  114.    fg_mousevis(OFF);
  115.    fg_restore(0,xlimit,menu_bottom,ylimit);
  116.    info_window(120,520,60,string,7);
  117.  
  118.    /* wait for a keystroke or mouse button */
  119.  
  120.    fg_mousevis(ON);
  121.    wait_for_keystroke();
  122.  
  123.    /* clear the screen and return to the menu */
  124.  
  125.    fg_mousevis(OFF);
  126.    fg_restore(0,xlimit,menu_bottom,ylimit);
  127.  
  128.    fg_mousevis(ON);
  129.    redraw = TRUE;
  130.  
  131.    return(OK);
  132. }
  133.  
  134. /**********************************************************************\
  135. *                                                                      *
  136. *  about_order -- information about ordering by phone                  *
  137. *                                                                      *
  138. \**********************************************************************/
  139.  
  140. int about_order()
  141. {
  142.    static char *string[] = {
  143.    "Order by Phone",
  144.    "Fastgraph version 2.01 is available for $149 as",
  145.    "of September 1991.  After December 1991, please",
  146.    "call (702) 735-1980 first for current prices.",
  147.    "",
  148.    "You can also use this number to order Fastgraph",
  149.    "or to request the Fastgraph/Light evaluation kit.",
  150.    "",
  151.    "We accept Visa and MasterCard.  Purchase orders",
  152.    "are welcome from most companies, schools, and",
  153.    "government agencies."
  154.    };
  155.  
  156.    /* clear the screen and display the info window */
  157.  
  158.    fg_mousevis(OFF);
  159.    fg_restore(0,xlimit,menu_bottom,ylimit);
  160.    info_window(120,520,60,string,11);
  161.  
  162.    /* wait for a keystroke or mouse button */
  163.  
  164.    fg_mousevis(ON);
  165.    wait_for_keystroke();
  166.  
  167.    /* clear the screen and return to the menu */
  168.  
  169.    fg_mousevis(OFF);
  170.    fg_restore(0,xlimit,menu_bottom,ylimit);
  171.  
  172.    fg_mousevis(ON);
  173.    redraw = TRUE;
  174.  
  175.    return(OK);
  176. }
  177.  
  178. /**********************************************************************\
  179. *                                                                      *
  180. *  about_site -- information about site licenses                       *
  181. *                                                                      *
  182. \**********************************************************************/
  183.  
  184. int about_site()
  185. {
  186.    static char *string[] = {
  187.    "Site Licenses",
  188.    "Site Licenses for Fastgraph are available.",
  189.    "Please call or write for details."
  190.    };
  191.  
  192.    /* clear the screen and display the info window */
  193.  
  194.    fg_mousevis(OFF);
  195.    fg_restore(0,xlimit,menu_bottom,ylimit);
  196.    info_window(152,488,60,string,3);
  197.  
  198.    /* wait for a keystroke or mouse button */
  199.  
  200.    fg_mousevis(ON);
  201.    wait_for_keystroke();
  202.  
  203.    /* clear the screen and return to the menu */
  204.  
  205.    fg_mousevis(OFF);
  206.    fg_restore(0,xlimit,menu_bottom,ylimit);
  207.  
  208.    fg_mousevis(ON);
  209.    redraw = TRUE;
  210.  
  211.    return(OK);
  212. }
  213.  
  214. /**********************************************************************\
  215. *                                                                      *
  216. *  about_tech -- information about technical support                   *
  217. *                                                                      *
  218. \**********************************************************************/
  219.  
  220. int about_tech()
  221. {
  222.    static char *string[] = {
  223.    "Technical Support",
  224.    "Call Dust Devil BBS (702) 796-7134 for updates,",
  225.    "examples, source code, and echo mail support.",
  226.    "Check your local boards for the U'NI-net / US",
  227.    "Fastgraph support conference.  For voice support",
  228.    "call Ted Gruber Software at (702) 735-1980.",
  229.    };
  230.  
  231.    /* clear the screen and display the info window */
  232.  
  233.    fg_mousevis(OFF);
  234.    fg_restore(0,xlimit,menu_bottom,ylimit);
  235.    info_window(120,520,60,string,6);
  236.  
  237.    /* wait for a keystroke or mouse button */
  238.  
  239.    fg_mousevis(ON);
  240.    wait_for_keystroke();
  241.  
  242.    fg_mousevis(OFF);
  243.    fg_restore(0,xlimit,menu_bottom,ylimit);
  244.  
  245.    fg_mousevis(ON);
  246.    redraw = TRUE;
  247.  
  248.    return(OK);
  249. }
  250.  
  251. /**********************************************************************\
  252. *                                                                      *
  253. *  exit_program -- exit to DOS if desired                              *
  254. *                                                                      *
  255. \**********************************************************************/
  256.  
  257. exit_program()
  258. {
  259.    int xmin, xmax, ymin, ymax;
  260.  
  261.    fg_mousevis(OFF);
  262.    fg_restore(0,xlimit,menu_bottom,ylimit);
  263.  
  264.    /* define the window extremes */
  265.  
  266.    xmin = 210;
  267.    xmax = 430;
  268.    ymin = scale(150);
  269.    ymax = scale(200);
  270.    if (mouse) ymax += 2 * ptsize;
  271.  
  272.    fg_mousevis(OFF);
  273.  
  274.    /* display the pop-up window */
  275.  
  276.    draw_window(xmin,xmax,ymin,ymax,"Exit");
  277.    fg_setcolor(0);
  278.    center_pstring("Exit to DOS?",xmin,xmax,ymin+row_offset(3));
  279.  
  280.    /* get the response and exit if desired */
  281.  
  282.    if (get_answer(xmin,xmax,ymin+row_offset(4))) terminate();
  283.  
  284.    /* otherwise, just clear the screen and return */
  285.  
  286.    fg_restore(0,xlimit,menu_bottom,ylimit);
  287.    redraw = TRUE;
  288.  
  289.    return(OK);
  290. }
  291.  
  292. /**********************************************************************\
  293. *                                                                      *
  294. *  print_form -- print the order form                                  *
  295. *                                                                      *
  296. \**********************************************************************/
  297.  
  298. int print_form()
  299. {
  300.    FILE *stream;
  301.    unsigned char key,aux;
  302.    char fstring[80];
  303.  
  304.    static char *string[] = {
  305.    "Print order form",
  306.    "Press ESC to stop printing"
  307.    };
  308.  
  309.    static char *string1[] = {
  310.    "Printer Error",
  311.    "Is the printer online?"
  312.    };
  313.  
  314.    static char *string2[] = {
  315.    "File Error",
  316.    "Missing file: ORDER.FRM"
  317.    };
  318.  
  319.    /* check that the printer is online */
  320.  
  321.    if (!printer_ready())
  322.    {
  323.       fg_mousevis(OFF);
  324.       fg_restore(0,xlimit,menu_bottom,ylimit);
  325.       info_window(120,520,60,string1,2);
  326.  
  327.       fg_mousevis(ON);
  328.       wait_for_keystroke();
  329.  
  330.       fg_mousevis(OFF);
  331.       fg_restore(0,xlimit,menu_bottom,ylimit);
  332.  
  333.       redraw = TRUE;
  334.       return(OK);
  335.    }
  336.  
  337.    /* check that the file can be opened */
  338.  
  339.    stream = fopen("order.frm","rt");
  340.    if (stream == NULL)
  341.    {
  342.       fg_mousevis(OFF);
  343.       fg_restore(0,xlimit,menu_bottom,ylimit);
  344.       info_window(120,520,60,string2,2);
  345.  
  346.       fg_mousevis(ON);
  347.       wait_for_keystroke();
  348.  
  349.       fg_mousevis(OFF);
  350.       fg_restore(0,xlimit,menu_bottom,ylimit);
  351.  
  352.       redraw = TRUE;
  353.       return(ERR);
  354.    }
  355.  
  356.    /* clear the screen and display the info window */
  357.  
  358.    fg_mousevis(OFF);
  359.    fg_restore(0,xlimit,menu_bottom,ylimit);
  360.    info_window(120,520,60,string,2);
  361.  
  362.    fg_mousevis(ON);
  363.  
  364.    /* print the file, one line at a time */
  365.  
  366.    while (TRUE)
  367.    {
  368.       if (fgets(fstring,80,stream) == NULL)
  369.          break;
  370.       fg_intkey(&key,&aux);
  371.       if (key == ESC)
  372.          break;
  373.       if (fprintf(stdprn,"%s\r",fstring) == 0)
  374.          break;
  375.    }
  376.  
  377.    /* print form feed */
  378.  
  379.    fprintf(stdprn,"\f");
  380.  
  381.    /* close the file and flush the printer buffer */
  382.  
  383.    fclose(stream);
  384.    fflush(stdprn);
  385.  
  386.    /* clear the screen and return to the menu */
  387.  
  388.    fg_mousevis(OFF);
  389.    fg_restore(0,xlimit,menu_bottom,ylimit);
  390.  
  391.    fg_mousevis(ON);
  392.    redraw = TRUE;
  393.  
  394.    return(OK);
  395. }
  396.  
  397. /**********************************************************************\
  398. *                                                                      *
  399. *  shell -- create a DOS command shell                                 *
  400. *                                                                      *
  401. \**********************************************************************/
  402.  
  403. shell()
  404. {
  405.    register int page;
  406.  
  407.    /* return to the original video mode */
  408.  
  409.    for (page = 1; page < PAGES; page++)
  410.       fg_freepage(page);
  411.    fg_mousepos(&xmouse,&ymouse,&buttons);
  412.    fg_setmode(old_mode);
  413.    fg_reset();
  414.  
  415.    /* spawn the DOS command shell */
  416.  
  417.    printf("\nEnter the command EXIT to return to the Fastgraph demo.");
  418.    spawnlp(P_WAIT,"command.com",NULL);
  419.  
  420.    /* upon return from DOS, restore the video context */
  421.  
  422.    fg_setmode(mode);
  423.    for (page = 1; page < PAGES; page++)
  424.       fg_allocate(page);
  425.    fg_sethpage(1);
  426.    visual = 0;
  427.    hidden = 1;
  428.  
  429.    /* redraw the screen */
  430.  
  431.    redraw = TRUE;
  432.    draw_screen();
  433.    fg_restore(0,xlimit,0,ylimit);
  434.    init_mouse();
  435.  
  436.    return(OK);
  437. }
  438.